{% extends 'base.html' %}
{% load mytags %}

{% block content %}
    {% include 'nav_cat_bar.html' %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-10">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>填写基本信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>

                    <div class="ibox-content">
                        <form id="groupForm" enctype="multipart/form-data" method="post" class="form-horizontal" action="">
                            {% csrf_token %}
                            {% if error %}
                                <div class="alert alert-warning text-center">{{ error }}</div>
                            {% endif %}
                            {% if msg %}
                                <div class="alert alert-success text-center">{{ msg }}</div>
                            {% endif %}

                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">产品名称</label>
                                <div class="col-sm-8">
                                    <input id="name" name="name" placeholder="产品名称" type="text" class="form-control" value="{{ name }}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="code" class="col-sm-2 control-label">产品代码</label>
                                <div class="col-sm-8">
                                    <input id="code" name="code" placeholder="产品代码" type="text" class="form-control" value="{{ code }}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="language_type" class="col-sm-2 control-label">开发语言</label>
                                <div class="col-sm-8">
                                    <select class="form-control " id="language_type" name="language_type">
                                        {% for p in languagetype_list %}
                                            <option value="{{ p|list_0 }}">{{ p|list_1 }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="git_url" class="col-sm-2 control-label">Git地址</label>
                                <div class="col-sm-8">
                                    <input id="git_url" name="git_url" placeholder="Git地址" type="text" class="form-control" value="{{ git_url }}">
                                </div>
                            </div>
{#                            <div class="hr-line-dashed"></div>#}
{#                            <div class="form-group">#}
{#                                <label for="git_branch" class="col-sm-2 control-label">Git Branch</label>#}
{#                                <div class="col-sm-8">#}
{#                                    <input id="git_branch" name="git_branch" placeholder="Git Branch" type="text" class="form-control" value="{{ git_branch }}">#}
{#                                </div>#}
{#                            </div>#}

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="env" class="col-sm-2 control-label">环境类型</label>
                                <div class="col-sm-8">
                                    <select class="form-control " id="env" name="env">
                                        {% for p in mvnenv_list %}
                                            <option value="{{ p|list_0 }}">{{ p|list_1 }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="is_full" class="col-sm-2 control-label">是否全量更新</label>
                                <div class="col-sm-8">
                                    <select class="form-control " id="is_full" name="is_full">
                                        {% for p in yesno_list %}
                                            <option value="{{ p|list_0 }}">{{ p|list_1 }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="idc" class="col-sm-2 control-label">机房</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="idc" name="idc">
                                        {% for p in idc_list %}
                                            <option value="{{ p }}">{{ p }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="host" class="col-sm-2 control-label">应用服务器IP</label>
                                <div class="col-sm-8">
                                    <input id="host" name="host" placeholder="多个应用服务器IP使用 | 分割" type="text" class="form-control" >
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="storage_host" class="col-sm-2 control-label">存储服务器IP</label>
                                <div class="col-sm-8">
                                    <input id="storage_host" name="storage_host" placeholder="存储服务器IP" type="text" class="form-control" >
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="src" class="col-sm-2 control-label">war包地址/源地址</label>
                                <div class="col-sm-8">
                                    <input id="srv" name="src" class="form-control" placeholder="war包地址/源地址" value="{{ src }}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="dest" class="col-sm-2 control-label">部署路径</label>
                                <div class="col-sm-8">
                                    <input id="dest" name="dest" class="form-control" placeholder="部署路径" value="{{ dest }}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="tomcat_num" class="col-sm-2 control-label">Tomcat编号</label>
                                <div class="col-sm-8">
                                    <input name="tomcat_num" id="tomcat_num" placeholder="Tomcat编号" class="form-control" value="{{ tomcat_num }}"/>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="backup_dir" class="col-sm-2 control-label">备份路径</label>
                                <div class="col-sm-8">
                                    <input id="backup_dir" name="backup_dir" class="form-control" placeholder="备份路径" value="{{ backup_dir }}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="ignore_setup" class="col-sm-2 control-label">忽略同步文件</label>
                                <div class="col-sm-8">
                                    <textarea id="ignore_setup" name="ignore_setup" class="form-control" placeholder="忽略同步文件" cols="6">{{ ignore_setup }}</textarea>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="ignore_backup" class="col-sm-2 control-label">忽略备份文件</label>
                                <div class="col-sm-8">
                                    <textarea id="ignore_backup" name="ignore_backup" class="form-control" placeholder="忽略备份文件" cols="6">{{ ignore_backup }}</textarea>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-white" type="reset">取消</button>
                                    <button id="submit_button" class="btn btn-primary" type="submit">创建</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}

{% block self_footer_js %}
<script>
$('#groupForm').validator({
    timely: 2,
    theme: "yellow_right_effect",
    rules: {
    },

    fields: {
        "name": {
            rule: "required",
            tip: "输入规则名称",
            msg: {required: "项目名称必填!"}
        },
        "host": {
            rule: "required",
            tip: "多个应用服务器用|分割",
            msg: {required: "应用服务器IP必填!"}
        },
        "storage_host": {
            rule: "required",
            tip: "输入规则名称",
            msg: {required: "存储服务器IP必填!"}
        },
        "code":{
            rule: "required",
            tip: "输入规则名称",
            msg: {required: "项目编码必填!"}
        },
        "src": {
            rule: "required",
            tip: "输入规则名称",
            msg: {required: "war包地址/源地址必填！"}
        },
        "dest": {
            rule: "required",
            tip: "输入规则名称",
            msg: {required: "部署路径必填！"}
        }
    },
    valid: function(form) {
            form.submit();
        }
});

</script>
{% endblock %}